// @ts-nocheck
import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'

const app = createApp(App)
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import router from './router';


app.use(ElementPlus)
app.use(createPinia())

import { userUserStore } from '@/stores'
const newRoute1 = {
    path: 'manage/student',
    component: () =>
        import ('@/views/student/studentManage/index.vue')
}
const newRoute2 = {
        path: 'manage/modifyKey',
        component: () =>
            import ('@/views/modifyKey/index.vue')
    }
    // const useStore = userUserStore()
function addRoutesByRole(role) {
    if (role === '老师') {
        router.addRoute('layout', newRoute1)
        router.addRoute('layout', newRoute2)
    }
}

async function setupRoutes() {
    const token = localStorage.getItem('token')
    if (token) {
        const role = userUserStore().getRole(); // 从你的用户 store 中获取角色
        addRoutesByRole(role);
    }
}

// 在 main.js 或者根组件的 created 钩子中调用此函数
setupRoutes();
app.use(router)


app.mount('#app')